package com.hlhj.funlike_businessqzxd.moudle;

import android.content.Context;

import com.example.mymvp.mvp.BaseModule;
import com.hlhj.funlike_businessqzxd.api.Apis;
import com.hlhj.funlike_businessqzxd.api.BaseObser;
import com.hlhj.funlike_businessqzxd.bean.FoodDetailBean;
import com.hlhj.funlike_businessqzxd.bean.MsgBean;
import com.lzy.okgo.model.Response;

public class MyCommodityDetailMoudle implements BaseModule{
    public interface getFoodDetail{
        void loadFoodDetail(FoodDetailBean.DataBean dataBean);

        void loadDelResult(String msg);
    }

    public getFoodDetail listener;

    public void setListener(getFoodDetail listener) {
        this.listener = listener;
    }

    public void LoadFoodDetail(Context context,int id){
        Apis.INSTANCE.FoodDetail(id)
                .subscribe(new BaseObser<Response<FoodDetailBean>>(context) {
                    @Override
                    public void httpSuccess(Response<FoodDetailBean> foodDetailBeanResponse) {
                        if (listener!=null){
                            listener.loadFoodDetail(foodDetailBeanResponse.body().getData());
                        }
                    }
                });
    }

    public void LoadDelFoodResult(Context context,int id){
        Apis.INSTANCE.FoodDel(id)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.loadDelResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }
}
